﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BSCMFF.Core.DataAccessLayer;
using BSCMFF.Core.Exceptions.Database;
using BSCMFF.Core;

namespace BSCMFF.Web.Pages.Administration
{
    public partial class DemoData : MultiLanguagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LabelStatus.Visible = false;
            LabelStatus2.Visible = false;
            LabelSuccessDelete.Visible = false;
        }

        protected void RadButtonInsertDemoData_Click(object sender, EventArgs e)
        {
            BSCEntities context = new BSCEntities();

            try
            {
                context.InsertDemoData();
                LabelStatus.Visible = false;
                LabelInstructions.Visible = true;
            }
            catch (Exception ex)
            {
                LabelStatus.Visible = true;
                LabelInstructions.Visible = false;
                //throw new InconsistentDatabaseException("Coulnd't create demo data: " + ex.Message);
            }
        }

        protected void RadButtonDeleteAllData_Click(object sender, EventArgs e)
        {
            BSCEntities context = new BSCEntities();

            int loggedAdminID = (int)Session["loggedUserID"];

            try
            {
                context.DeleteDemoData(loggedAdminID);
                LabelSuccessDelete.Visible = true;
            }
            catch (Exception ex)
            {
                LabelStatus2.Visible = true;
                //LabelStatus.Text = "Data couldn't be deleted";
                //throw new InconsistentDatabaseException("Coulnd't delete data: " + ex.Message);
            }
        }
        
    }
}